/*
 * Copyright (c) 2010 Andy Aspell-Clark
 * 
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */
package uk.org.aspellclark.agenedb.gedcom.model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * The address structure should be formed as it would appear on a mailing label
 * using the ADDR and the CONT lines to form the address structure.
 * <p>
 * The ADDR and CONT lines are required for any address. The additional
 * subordinate address tags such as STAE and CTRY are provided to be used by
 * systems that have structured their addresses for indexing and sorting. For
 * backward compatibility these lines are not to be used in lieu of the required
 * ADDR.and CONT line structure.
 * 
 * <table>
 * <tr>
 * <td>n</td>
 * <td>ADDR</td>
 * <td><ADDRESS_LINE></td>
 * <td>&nbsp;</td>
 * <td>{1:1}</td>
 * <td>p.41</td>
 * </tr>
 * <tr>
 * <td>&nbsp;</td>
 * <td>+1</td>
 * <td>CONT</td>
 * <td><ADDRESS_LINE></td>
 * <td>{0:3}</td>
 * <td>p.41</td>
 * </tr>
 * <tr>
 * <td>&nbsp;</td>
 * <td>+1</td>
 * <td>ADR1</td>
 * <td><ADDRESS_LINE1></td>
 * <td>{0:1}</td>
 * <td>p.41</td>
 * </tr>
 * <tr>
 * <td>&nbsp;</td>
 * <td>+1</td>
 * <td>ADR2</td>
 * <td><ADDRESS_LINE2></td>
 * <td>{0:1}</td>
 * <td>p.41</td>
 * </tr>
 * <tr>
 * <td>&nbsp;</td>
 * <td>+1</td>
 * <td>ADR3</td>
 * <td><ADDRESS_LINE3></td>
 * <td>{0:1}</td>
 * <td>p.41</td>
 * </tr>
 * <tr>
 * <td>&nbsp;</td>
 * <td>+1</td>
 * <td>CITY</td>
 * <td><ADDRESS_CITY></td>
 * <td>{0:1}</td>
 * <td>p.41</td>
 * </tr>
 * <tr>
 * <td>&nbsp;</td>
 * <td>+1</td>
 * <td>STAE</td>
 * <td><ADDRESS_STATE></td>
 * <td>{0:1}</td>
 * <td>p.42</td>
 * </tr>
 * <tr>
 * <td>&nbsp;</td>
 * <td>+1</td>
 * <td>POST</td>
 * <td><ADDRESS_POSTAL_CODE></td>
 * <td>{0:1}</td>
 * <td>p.41</td>
 * </tr>
 * <tr>
 * <td>&nbsp;</td>
 * <td>+1</td>
 * <td>CTRY</td>
 * <td><ADDRESS_COUNTRY></td>
 * <td>{0:1}</td>
 * <td>p.41</td>
 * </tr>
 * </table>
 * 
 * @author andy.aspell-clark
 */
public class Address extends GedcomStructure {

	public List<String> lines = new ArrayList<String>();

	public String addr1;
	public String addr2;
	public String city;
	public String stateProvince;
	public String postalCode;
	public String country;

	/**
	 * Default Constructor.
	 */
	public Address() {
	}

	@Override
	public String toString() {
		if (this.addr1 != null && this.addr1.length() > 0) {
			return this.addr1 + ", " + (this.addr2 != null ? this.addr2 : "") + ", "
					+ (this.city != null ? this.city : 22) + ", " + (this.stateProvince != null ? this.stateProvince : "")
					+ ", " + (this.postalCode != null ? this.postalCode : "");
		}
		return "no address";
	}
}
